from django.db import models

# Create your models here.
from django.utils import timezone

class danweibiao(models.Model):
	xuhao     = models.IntegerField(verbose_name="序号")
	quancheng = models.CharField(max_length=50, verbose_name="单位全称")
	jiancheng = models.CharField(max_length=50,verbose_name="单位简称",unique=True, blank=True )
	leixing   = models.CharField(max_length=50, verbose_name="单位类型", choices=["政府机关", "事业单位" ,"参公事业单位" ], blank=True)
	xitong    = models.CharField(max_length=50,verbose_name="所属系统", choices=[
		"党群","政府办", "政法", "宣传", "发改委", "农林水", "财经", "经贸",  "经开区",  "战新办",  "乡镇",  "垂直单位"])
	zhishuzongsu    = models.TextField(blank=True, verbose_name="职数综述")
	banzishu  = models.IntegerField(blank=True, verbose_name="班子数")
	zhengzhishu = models.IntegerField(blank=True, verbose_name="正职数")
	fuzhishu    = models.IntegerField(blank=True, verbose_name="副职数")
	dangzuchengyuanshu    = models.IntegerField(blank=True, verbose_name="党组（委）成员数")
	qitazhishu    = models.IntegerField(blank=True, verbose_name="其他领导职数")
	def __str__(self):
		return self.jiancheng
	class Meta:
#		ordering = ['-xuhao']
		verbose_name_plural  = "单位信息"

class renyuanbiao(models.Model):
	"""docstring for renyuanbiao"""
	xingming = models.CharField(max_length=8,unique=True)
	shenfenzhenghao = models.CharField(max_length=18,blank=True,null=True)

	zhao_pian = models.ImageField(upload_to='static/Photos/',default="")

	def __str__(self):
		return self.xingming
	class Meta:
#		ordering = ['-xuhao']
		verbose_name_plural  = "干部信息"

class zhiweibiao(models.Model):
	"""docstring for zhiweibiao"""
	xuhao = models.IntegerField(verbose_name="序号")
	jiancheng = models.ForeignKey(danweibiao, on_delete=models.CASCADE,to_field='jiancheng',default="")
	xingming = models.ForeignKey(renyuanbiao, on_delete=models.CASCADE,to_field='xingming',default="")
	zhiwu = models.CharField(max_length=20,blank=True,null=True)
	shifoubanzi = models.CharField(max_length=20,blank=True,null=True)
	zhiji = models.CharField(max_length=20,blank=True,null=True)
	renxianzhijishijian = models.DateField(blank=True,null=True)
	def __str__(self):
		return self.zhiwu
	class Meta:
#		ordering = ['-xuhao']
		verbose_name_plural  = "职位信息"
		
class renmianbiao(models.Model):
	"""docstring for renmianbiao"""
	xingming = models.ForeignKey(renyuanbiao, on_delete=models.DO_NOTHING,to_field='xingming',default="")

